﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using ThreeByte.ActiveDeck.Config;
using System.Xml.Linq;
using System.Net;
using System.Xml;
using System.ComponentModel;
using ThreeByte.ActiveDeck.Data;
using ThreeByte.ActiveDeck.Service;
using System.Threading;
using ThreeByte.ActiveDeck.Content;
using Microsoft.Office.Interop.PowerPoint;
using ThreeByte.ActiveDeck.AddIn.Config;
using ThreeByte.Media;
using ThreeByte.ActiveDeck.AddIn.Controls;
using ThreeByte.ActiveDeck.AddIn.Content.Controls;


namespace ThreeByte.ActiveDeck.Controls
{
    /// <summary>
    /// Interaction logic for DataCommandControl.xaml
    /// </summary>
    public partial class DataCommandControl : UserControl, ICloseable
    {

        public event EventHandler<DialogResultEventArgs> Close;

        public DataCommandControl(string commandData = null) {
            InitializeComponent();

            Tag = "Configure Data Command"; //Implemented to support customized title bar in Forms Host

            DoneButton.DataContext = this;

            if(commandData != null) {
                CommandText.Text = commandData;
            }
        }



        private void CancelButton_Click(object sender, RoutedEventArgs e) {
            if(Close != null) {
                Close(this, new DialogResultEventArgs(System.Windows.Forms.DialogResult.Cancel));
            }
        }

        public NavigationAction ConfiguredAction {
            get {
                NavigationAction newAction = new NavigationAction();
                newAction.Command = true;
                newAction.CommandData = CommandText.Text;
                return newAction;
            }
        }

        private void DoneButton_Click(object sender, RoutedEventArgs e) {

            if(string.IsNullOrWhiteSpace(CommandText.Text)){
                MessageBox.Show("Please enter some data to send", "Invalid Data");
                return;
            }

            if(Close != null) {
                Close(this, new DialogResultEventArgs(System.Windows.Forms.DialogResult.OK));
            }
        }

       

       
    }
}
